function findAndCount(a, v) {
    let count = 0
    for(let i = 0; i < a.length; i++) {
        if(a[i] == v) count++
        if(a[i] > v) break
    }
    return count
}
console.log(findAndCount([1, 3, 4, 4, 4, 5, 6], 4));